package arraylist;

import java.util.ArrayList;
/*
* ArrayList存储自定义引用类型
*  集合中存储元素,本质上存储的是对象的地址值
*  将来可以根据地址值找到对象
* */
public class ArrayListDemo06 {
    public static void main(String[] args) {
        ArrayList<Person> people = new ArrayList<>();
        Person p1 = new Person("张三", "18");
        Person p2 = new Person("李四", "19");
        Person p3 = new Person("王五", "16");

        people.add(p1);
        people.add(p2);
        people.add(p3);
        System.out.println(people);

        for (Person p : people) {
            System.out.println(p.getName() + "  " + p.getAge());
        }
    }
}
